//
//  SettingsViewController.m
//  ZhuKuang
//
//  Created by jayce on 17/7/11.
//  Copyright © 2017年 jjkj. All rights reserved.
//

#import "SettingsViewController.h"

@interface SettingsViewController ()

@property (weak, nonatomic) IBOutlet UITextField *ipTF;
@property (weak, nonatomic) IBOutlet UITextField *portTF;
- (IBAction)p_sureAction:(id)sender;
- (IBAction)p_cancelAction:(id)sender;

@end

@implementation SettingsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)p_sureAction:(id)sender {
    
    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:self.ipTF.text forKey:IP];
    [defaults setObject:self.portTF.text forKey:PORT];
    [defaults synchronize];
    
    [MBProgressHUD postMessageWithText:@"设置成功" View:kWindow];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self dismissViewControllerAnimated:YES completion:nil];
    });
}

- (IBAction)p_cancelAction:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
